<?php

/**
 * Lexiquedefinition filter form base class.
 *
 * @package    explications_informatiques
 * @subpackage filter
 * @author     Guimezanes Cyrille
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseLexiquedefinitionFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_mot'               => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Lexiquemot'), 'add_empty' => true)),
      'id_auteur'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile'), 'add_empty' => true)),
      'definition'           => new sfWidgetFormFilterInput(),
      'vote'                 => new sfWidgetFormFilterInput(),
      'online'               => new sfWidgetFormFilterInput(),
      'view_by_mode'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
    ));

    $this->setValidators(array(
      'id_mot'               => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Lexiquemot'), 'column' => 'idlexique_mot')),
      'id_auteur'            => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('SfGuardUserProfile'), 'column' => 'id')),
      'definition'           => new sfValidatorPass(array('required' => false)),
      'vote'                 => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'online'               => new sfValidatorPass(array('required' => false)),
      'view_by_mode'         => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('lexiquedefinition_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Lexiquedefinition';
  }

  public function getFields()
  {
    return array(
      'idlexique_definition' => 'Number',
      'id_mot'               => 'ForeignKey',
      'id_auteur'            => 'ForeignKey',
      'definition'           => 'Text',
      'vote'                 => 'Number',
      'online'               => 'Text',
      'view_by_mode'         => 'Text',
    );
  }
}
